package com.example.domain.info;

import java.util.HashMap;

public class ResultMap extends HashMap<String,Object> {

    /**
     * 默认data键值
     */
    public static final String DEFAULT_DATA = "data";
    /**
     * 默认code键值
     */
    public static final String DEFAULT_CODE = "code";
    /**
     * 未知数据
     */
    public static final Integer UN_KNOW = -1;

    /**
     * 飞机姿态信息
     */
    public static final Integer ACTION_CODE = 1;
    /**
     * pid信息
     */
    public static final Integer PID_CODE = 2;
    /**
     * 等待pid确认帧
     */
    public static final Integer WAIT_PID_CHECK = 20;
    public static final Integer PID_CHECK_SUCCESS = 21;
    public static final Integer PID_CHECK_ERROR = 22;
    public static final Integer PID_REQUEST_SUCCESS = 25;
    /**
     * 串口异常中断
     */
    public static final Integer SERIAL_PORT_ERROR = -2;

    public static ResultMap getResult(){
        return new ResultMap();
    }

    public static ResultMap getResult(Object data){
        return new ResultMap().put(DEFAULT_DATA,data);
    }

    public static ResultMap getResult(Object data,Integer code){
        return new ResultMap().put(DEFAULT_DATA,data).put(DEFAULT_CODE,code);
    }

    @Override
    public ResultMap put(String key, Object value) {
        super.put(key, value);
        return this;
    }
}
